pp108 : Mathematical Functions of Rule Engine

Mathematical Functions of Rule Engine

This topic describes the various mathematical functions available in the default rule engine function library.


Mathematical functions can be used to perform mathematical operations on data, following the XPath Notations.

Apart from basic mathematical operations such as addition, subtraction, and so on, you can use functions to round off numbers to the nearest integer, and find the sum of all the numeric values in a nodeset.

The following table describes the various mathematical functions available in the rule engine function library and their usage.

Table 1. Rule Engine Mathematical Functions

Mathematical Functions

Description

Usage

sum(e)

Returns the sum of the numeric value of each node in the specified node-set

sum(e), where
e is the nodeset.For example: sum(Item/Quantity) returns the sum of all the numeric values of the Quantity nodeset in the Item object.

floor(e)

Returns the largest integer that is not greater than the number argument

floor(e), where
e is a numeric expression.For example: floor(44.12) returns the value 44.

ceiling(e)

Returns the smallest integer that is greater than the number argument

ceiling(e), where
e is a numeric expression.For example: ceiling(44.12) returns the value 45.

round(e)

Rounds the number argument to the nearest integer

round(e), where
e is a numeric expression.For example: round(44.12) returns the value 44.